package com.kofigyan.stateprogressbarsample;

import com.kofigyan.stateprogressbarsample.not_stateprogressbar.adapter.ApiFeatureAdapter;
import com.kofigyan.stateprogressbarsample.not_stateprogressbar.adapter.OnListItemClickListener;
import com.kofigyan.stateprogressbarsample.not_stateprogressbar.pojo.ApiFeature;
import com.kofigyan.stateprogressbarsample.not_stateprogressbar.utils.AbilityToAbility;
import com.kofigyan.stateprogressbarsample.not_stateprogressbar.utils.Constants;
import com.kofigyan.stateprogressbarsample.not_stateprogressbar.utils.Utils;
import ohos.aafwk.content.Intent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MainAbility extends ListBaseActivity {

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        List<ApiFeature> features = getApiFeatures();

        ApiFeatureAdapter adapter = new ApiFeatureAdapter(this, features, new OnListItemClickListener<ApiFeature>() {
            @Override
            public void onItemClick(ApiFeature data, int position) {
                Map<String, Object> params = new HashMap<>();
                params.put(Constants.IS_DESCENDING_ASCENDING_OPTIONS, true);
                AbilityToAbility.toAbility(getContext(),
                        Utils.selectActivity(position, Utils.allActivities),
                        params);
            }
        });
        recyclerView.setItemProvider(adapter);
    }

    @Override
    protected int getLayoutId() {
        return ResourceTable.Layout_ability_main;
    }

    private List<ApiFeature> getApiFeatures() {

        List<ApiFeature> features = new ArrayList<>();

        String[] titles = new String[]{
                "States",
                "Check",
                "Check 2",
                "Animation",
                "Description",
                "Dimension",
                "Color",
                "Usage",
        };

        String[] descriptions = new String[]{
                "Basic demo with different states",
                "Check states completed demo",
                "All states completed demo",
                "Animate to current state demo",
                "Describe each state demo",
                "Changing state dimensions demo",
                "Coloring state and decription demo",
                "Real world example",
        };

        for (int i = 0; i < titles.length; i++) {
            features.add(new ApiFeature(titles[i], descriptions[i]));
        }

        return features;
    }
}
